const express = require('express')
const router = express.Router()

const jwt = require('jsonwebtoken')
const passport = require('passport')

const { AdminRoleAuthority } = require('./../controller/admin/adminRoleAuthority')
const { AdminUser } = require('./../controller/admin/adminUsers')
const { AdminSystemLog } = require('./../controller/admin/adminSystemLog')
const { Users } = require('./../controller/admin/user')
const { UserRole } = require('./../controller/admin/userRoleAuthority')

/**
 * 管理员
 */
// 测试
router.get('/helloworld', AdminUser.helloworld)
// 验证码
router.get('/getCode', AdminUser.getCode)
// 登录
router.post('/adminSignIn', AdminUser.adminSignIn)
// 注册
router.post('/createAdminUser', passport.authenticate('jwt', { session: false }), AdminUser.createAdminUser)
// 编辑
router.put('/editAdminUser', passport.authenticate('jwt', { session: false }), AdminUser.editAdminUser)
// 列表显示
router.get('/getAdminUserList', passport.authenticate('jwt', { session: false }), AdminUser.getAdminUserList)
// 用户信息
router.get('/getAdminUserInfo', passport.authenticate('jwt', { session: false }), AdminUser.getAdminUserInfo)
// 删除用户
router.delete('/deleteAdminUser', passport.authenticate('jwt', { session: false }), AdminUser.deleteAdminUser)

/**
 * 系统日志
 */
// 日志列表
router.get('/getAdminSystemLogList', passport.authenticate('jwt', { session: false }), AdminSystemLog.getAdminSystemLogList)
// 删除日志
router.get('/deleteAdminSystemLog', passport.authenticate('jwt', { session: false }), AdminSystemLog.deleteAdminSystemLog)

/**
 * 系统权限
 */
// 创建权限
router.post('/createAdminRole', passport.authenticate('jwt', { session: false }), AdminRoleAuthority.createAdminRole)
// 编辑权限
router.put('/editAdminRole', passport.authenticate('jwt', { session: false }), AdminRoleAuthority.editAdminRole)
// 删除权限
router.delete('/deleteAdminRole', passport.authenticate('jwt', { session: false }), AdminRoleAuthority.deleteAdminRole)
// 权限用户关联
router.post('/createAdminUserRole', passport.authenticate('jwt', { session: false }), AdminRoleAuthority.createAdminUserRole)
// 角色权限关联
router.post('/setAdminRoleAuthority', passport.authenticate('jwt', { session: false }), AdminRoleAuthority.setAdminRoleAuthority)
// 获取用户权限列表
router.get('/getAdminRoleList', passport.authenticate('jwt', { session: false }), AdminRoleAuthority.getAdminRoleList)
// 获取权限所有数据
router.get('/getAdminRoleAll', passport.authenticate('jwt', { session: false }), AdminRoleAuthority.getAdminRoleAll)
// 获取菜单
router.get('/getMenu', passport.authenticate('jwt', { session: false }), AdminRoleAuthority.getMenu)
/**
 * 用户列表
 */
// 分页获取
router.get('/getUserList', passport.authenticate('jwt', { session: false }), Users.getUserList)
// 编辑用户
router.put('/editUser', passport.authenticate('jwt', { session: false }), Users.editUser)
// 删除用户
router.delete('/deleteUser', passport.authenticate('jwt', { session: false }), Users.deleteUser)
// 获取用户图片列表
router.get('/getAvatarReview', passport.authenticate('jwt', { session: false }), Users.getAvatarReview)
// 审核用户图片
router.post('/set_avatar_review', passport.authenticate('jwt', { session: false }), Users.set_avatar_review)
// 用户禁言
router.post('/banUser', passport.authenticate('jwt', { session: false }), Users.banUser)
module.exports = router